//
//  loginViewController.swift
//  股票框架
//
//  Created by 李小骥 on 2017/9/28.
//  Copyright © 2017年 李小骥. All rights reserved.
//

import UIKit
import RxSwift
import RxCocoa
import SnapKit
import QuartzCore
enum JumpFrom:String{
    case home = "home"
    case school = "school"
    case broadcast = "broadcast"
    case my = "my"
    func returnUrlString() -> String{
        switch self {
        case .home:
            return "http://xy.cctvzxjy.com/Index/index/s/1"
        case .school:
            return "http://xy.cctvzxjy.com/Bunch/index"
        case .broadcast:
            return "http://xy.cctvzxjy.com/Live/index"
        case .my://安全起见默认返回首页
            return "MyData"
        }
    }
}
class LoginViewController: UIViewController {
    @IBOutlet weak var thirdPartyLoginThinLineRight: UIImageView!
    @IBOutlet weak var thirdPartyLoginThinLineLeft: UIImageView!
    @IBOutlet weak var WeiboLoginLabel: UILabel!
    @IBOutlet weak var thinLineBottom: UIImageView!
    @IBOutlet weak var WechatLoginLabel: UILabel!
    @IBOutlet weak var QQLoginLabel: UILabel!
    @IBOutlet weak var WechatLoginButton: UIButton!
    @IBOutlet weak var loginButton: UIButton!
    @IBOutlet weak var verificationCodeLabel: UILabel!
    @IBOutlet weak var QQLoginButton: UIButton!
    @IBOutlet weak var thirdPartyLoginLabel: UILabel!
    @IBOutlet weak var thinLineTop: UIImageView!
    @IBOutlet weak var logo: UIImageView!
    @IBOutlet weak var phoneNumberTextField: UITextField!
    @IBOutlet weak var verificationCodeTextField: UITextField!
    @IBOutlet weak var phoneNumberLabel: UILabel!
    @IBOutlet weak var WeiboLoginButton: UIButton!    
    @IBOutlet weak var verificationCodeButton: UIButton!
    weak var homeWebViewDelegate:homeViewController?
    weak var schoolWebViewDelegate:schoolViewController?
    weak var broadcastWebViewDelegate:broadcastViewController?
    weak var myViewDelegate:MyViewController?
//倒计时用 timer
    var countdownTimer: Timer?
    var registerUrl : String = ""
    var jumpFrom : JumpFrom!
    //    倒计时的秒数
    var remainingSeconds: Int = 0 {
        willSet {
            verificationCodeButton.setTitle("\(newValue)s", for: .disabled)
            
            if newValue <= 0 {

                
                isCounting = false
            }
        }
    }
//    控制倒计时状态的开关
    var isCounting = false {
        willSet {
//            新值是从 false 变成 true 时
            if newValue {
                //                通常使用#Selector 进行访问，xcode 做类型检查，只有涉及到系统的私有方法时（例如父类的 private 方法不能被继承和访问），才会使用 Selector（“方法名”）的方式，极其容易崩
                countdownTimer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(LoginViewController.updateTime(_:)), userInfo: nil, repeats: true)
                
                remainingSeconds = 60
                verificationCodeButton.isEnabled = false
                verificationCodeButton.setTitleColor(.APP, for: .disabled)
                verificationCodeButton.backgroundColor = .white
            } else {
//                新值是从 true 变成 false 时
                countdownTimer?.invalidate()
                countdownTimer = nil
                verificationCodeButton.isEnabled = true
                verificationCodeButton.setTitleColor(.APP, for: .normal)
                verificationCodeButton.setTitle("重新获取验证码", for: .normal)
            }
            
            verificationCodeButton.isEnabled = !newValue
        }
    }
    //    swift 的私有方法需要声明为 runtime 才能被#Selector 找到，声明方式是@objc
    @objc func updateTime(_ timer: Timer) {
        remainingSeconds -= 1
    }
    @IBAction func loginRequest(_ sender: Any) {
        let phoneNumber = phoneNumberTextField.text!
        let code = verificationCodeTextField.text!
        weak var weakSelf:LoginViewController? = self
        //            定义异步网络请求的回调代码块：形参表列代表网络请求传回来的数据，代码块的执行体代表后续的处理
        let loginSucceeded:((Bool)->(Void)) = { result in
            if(result==true){
//                if (weakSelf?.registerUrl != ""){
//                发出通知给3个 web 页面刷新
                    weakSelf?.signInOtherViewControllers(jumpFrom:(weakSelf?.jumpFrom)!)
//                }
            weakSelf?.backNative()
                }
                else{
                weakSelf?.phoneNumberLabel.text = "登录失败"
            }
        }
        Utils.AlamofireAsynchronousPOSTPhoneNumber(pNumber: phoneNumber, verificationCode: code, callBack:loginSucceeded)
        
//        if(loginSucceeded == true){
//            self.navigationController?.popViewController(animated: true)
//        }
//        else{
//            loginStatus.text = "登录失败"
        /*
         
         */
        }
    func signInOtherViewControllers(jumpFrom:JumpFrom){//待修改
        print("来到了这里")
        switch jumpFrom {
        case .home:
            if let homeDelegate = homeWebViewDelegate {
                homeDelegate.loadUrl = homeDelegate.convertToAccessableUrl(registerUrl:registerUrl)
                
            }
        case .school:
            if let schoolDelegate = schoolWebViewDelegate {
                schoolDelegate.loadUrl = schoolDelegate.convertToAccessableUrl(registerUrl:registerUrl)
                
            }
        case .broadcast:
            if let broadcastDelegate = broadcastWebViewDelegate {
                broadcastDelegate.loadUrl = broadcastDelegate.convertToAccessableUrl(registerUrl:registerUrl)
                
            }
        case .my:
            if let myDelegate = myViewDelegate {
                myDelegate.signIn()
            }
        }
        
        
//        !!!!有用，改完学院和直播之后用！！！
//        if let schoolDelegate = schoolWebViewDelegate {
//            if(schoolDelegate.webView.isLoading){
//                schoolDelegate.webView.stopLoading()
//            }
//            schoolDelegate.webView.reload()
//        }
//        if let broadcastDelegate = broadcastWebViewDelegate {
//            if(broadcastDelegate.webView.isLoading){
//                broadcastDelegate.webView.stopLoading()
//            }
//            broadcastDelegate.webView.reload()
//        }
    }
        func observeTextfields(){
            let phoneNo = "^1[0-9]{10}$"
            let predicate = NSPredicate(format: "SELF MATCHES %@", phoneNo)
//            let phoneNumberObserable = phoneNumberTextField.rx_text.shareReplay(1).map({predicate.evaluate(with: $0)})
            let phoneNumberObserable = phoneNumberTextField.rx.text.shareReplay(1).map({predicate.evaluate(with: $0)})
            let verificationCodeObserable = verificationCodeTextField.rx.text.shareReplay(1).map({$0?.characters.count == 4})
//            let a = type(of: self)
            weak var weakSelf:LoginViewController? = self
            _ = Observable.combineLatest(phoneNumberObserable, verificationCodeObserable) {$0 && $1}.subscribe({ (valid) in
                guard let ele = valid.element,ele == true else{
                    weakSelf?.loginButton.isEnabled = false
                    return
                }
                    weakSelf?.loginButton.isEnabled = true
                    //                    weakSelf?.loginButton.backgroundColor = UIColor.redColor()
                
            })
//            ({valid in
//                if valid{
//                    weakSelf?.loginButton.enabled = true
////                    weakSelf?.loginButton.backgroundColor = UIColor.redColor()
//                }else{
//                    weakSelf?.loginButton.enabled = false
////                    self.registerButton.backgroundColor = UIColor.darkGrayColor()
//                }
//            }).addDisposable
//        }
        
    }
    @IBAction func verificationCodeRequest(_ sender: Any) {
        if let phoneNumber = phoneNumberTextField.text{
//            定义异步网络请求的回调代码块：形参表列代表网络请求传回来的数据，代码块的执行体代表后续的处理
        let requestVerificationCodeSucceeded:((Bool)->(Void)) = { result in
            if(result==true){
                self.isCounting = true
            }
            else{
                self.verificationCodeButton.setTitle("验证码请求错误", for: .normal)
            }
        }
            let verificationCodeRequestSecceeded = Utils.AlamofireAsynchronousPOSTPhoneNumber(pNumber:phoneNumber, callBack:requestVerificationCodeSucceeded)
//            if(verificationCodeRequestSecceeded == true){
//                isCounting = true
//            }
//            else{
//                verificationCodeButton.setTitle("验证码请求错误", for: .normal)
//            }
        }
//        Utils.requestTokenWithPhoneNumber(pNumber: phoneNumber!)
    }
    override func viewWillAppear(_ animated: Bool) {
        navigationController?.navigationBar.setBackgroundColor(.APP)
        makeReturnButton()
    }
    func returnButtonTitle()->String{
        switch jumpFrom {
        case .home:
            return "首页"
        case .school:
            return "学院"
        case .broadcast:
            return " 直播"
        case .my:
            return " 我的"
        case .none:
            return "返回"
        case .some(_):
            return "返回"
        }
    }
    func makeReturnButton(){
        let leftButtonView = UIView(frame: CGRect(x: 0, y: 0, width: 60, height: 40))
        let leftButton = UIButton(type: .system)
        leftButton.backgroundColor = .clear
        leftButton.frame = leftButtonView.frame
        leftButton.setImage(UIImage(named:"左侧返回"), for: .normal)
        leftButton.setTitle(RETURNBUTTONTITLEMARGIN+returnButtonTitle(), for: .normal)
        leftButton.tintColor = .white
        leftButton.autoresizesSubviews = true
        leftButton.contentHorizontalAlignment = .left
        leftButton.autoresizingMask = UIViewAutoresizing(rawValue: (UIViewAutoresizing.flexibleWidth.rawValue | UIViewAutoresizing.flexibleLeftMargin.rawValue))
        
        leftButton.contentEdgeInsets = UIEdgeInsets(top: 0, left: -15, bottom: 0, right: 0)
        leftButton.addTarget(self, action: #selector(backNative), for: .touchUpInside)
        leftButtonView.addSubview(leftButton)
        let leftBarButton = UIBarButtonItem(customView: leftButtonView)
        navigationItem.leftBarButtonItem = leftBarButton
    }
    @objc func backNative(){
        navigationController?.dismiss(animated: true, completion: nil)
    }
    func addCompleteButton(){
        //完成按钮所在的工具栏
        let inputComplete=UIToolbar(frame: CGRect(x: 0, y: 200, width: SCREEN_WIDTH, height: 40))
        inputComplete.isHidden = false
        inputComplete.backgroundColor = .red
        //        inputComplete.sizeToFit()
        //工具栏上添加完成按钮
        let spaceBtn = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil)
        let closeItem=UIBarButtonItem(title: "完成", style: UIBarButtonItemStyle.done, target: self, action: (#selector(close)))
        inputComplete.items = [spaceBtn, closeItem]
        //完成附加在键盘上
        //        let textField = searchBar.value(forKey: "searchField") as! UITextField
        //        textField.inputAccessoryView = inputComplete
        phoneNumberTextField.inputAccessoryView = inputComplete
        phoneNumberTextField.inputAccessoryView?.isHidden = false
        verificationCodeTextField.inputAccessoryView = inputComplete
        verificationCodeTextField.inputAccessoryView?.isHidden = false
    }
    @objc func close(){
        if(phoneNumberTextField.isFirstResponder==true){
            phoneNumberTextField.resignFirstResponder()
        }
        if(verificationCodeTextField.isFirstResponder==true){
            verificationCodeTextField.resignFirstResponder()
        }
    }
    func addKeyboardNotification(){
        weak var weakSelf:LoginViewController? = self
        NotificationCenter.default.rx.notification(Notification.Name.UIKeyboardWillShow, object: nil).map { (notification) -> Void in
            let userInfo = notification.userInfo as! NSDictionary
            let value = userInfo.object(forKey: UIKeyboardFrameEndUserInfoKey) as! NSValue
            var keyboardRect = value.cgRectValue
            keyboardRect = (weakSelf?.view.convert(keyboardRect, from: nil))!
            let keyboardHeight = keyboardRect.size.height
            var frame = weakSelf?.view.bounds
            let newSize = CGSize(width: (frame?.size.width)!, height: (frame?.size.height)! - keyboardHeight)
            let newFrame = CGRect(origin: (frame?.origin)!, size: newSize)
            weakSelf?.view.frame = newFrame
        }
        NotificationCenter.default.rx.notification(Notification.Name.UIKeyboardWillHide, object: nil).map { (notification) -> Void in
            let keyboardHeight = 0
            weakSelf?.view.frame = (weakSelf?.view.bounds)!
        }
    }
    override func viewDidLoad() {
        super.viewDidLoad()
        phoneNumberTextField.keyboardType = .numberPad
        verificationCodeTextField.keyboardType = .numberPad
        addCompleteButton()
        addKeyboardNotification()
        
        verificationCodeButton.setTitleColor(.APP, for: .normal)
        WeiboLoginButton.setTitleColor(.APP, for: .normal)
        SNPSetWidgets()
        observeTextfields()
        
//        暂时隐藏三方登录，下一版做出来
        QQLoginButton.isHidden = true
        WeiboLoginButton.isHidden = true
        WechatLoginButton.isHidden = true
        QQLoginLabel.isHidden = true
        WeiboLoginLabel.isHidden = true
        WechatLoginLabel.isHidden = true
        thirdPartyLoginLabel.isHidden = true
        thirdPartyLoginThinLineLeft.isHidden = true
        thirdPartyLoginThinLineRight.isHidden = true
        
//        let phoneNumberObserable = phoneNumberTextField.rx_text.shareReplay(1).map {
//            $0.characters.count > 6
//        }
////        let verificationCodeObserable = phoneNumberTextField.rx_text.shareReplay(1).map {
//            $0.characters.count > 6
//        }

        // Do any additional setup after loading the view.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    func SNPSetWidgets(){
        SNPSetLogo()
        SNPSetPhoneNumberLabel()
        SNPSetPhoneNumberTextField()
        SNPSetVerificationCodeButton()
        SNPSetThinLineTop()
        SNPSetVerificationCodeLabel()
        SNPSetVerificationCodeTextField()
        SNPSetThinLineBottom()
        SNPSetLoginButton()
        SNPSetThirdPartyLoginThinLineLeft()
        SNPSetThirdPartyLoginLabel()
        SNPSetThirdPartyLoginThinLineRight()
        SNPSetQQLoginButton()
        SNPSetWechatLoginButton()
        SNPSetWeiboLoginButton()
        SNPSetQQLoginLabel()
        SNPSetWechatLoginLabel()
        SNPSetWeiboLoginLabel()
    }
    
    func SNPSetLogo(){
        logo.image = UIImage(named: "图标")
        logo.snp.makeConstraints { (make) -> Void in
            make.top.equalTo(90)
            make.left.equalTo(102)
            make.right.equalTo(-102)
            make.height.equalTo(logo.snp.width)
        }
    }
    func SNPSetPhoneNumberLabel(){
        phoneNumberLabel.snp.makeConstraints { (make) -> Void in
            make.top.equalTo(logo.snp.bottom).offset(60)
            make.left.equalTo(20)
        }
        phoneNumberLabel.font = UIFont(name: "PingFangSC", size: 17)
        phoneNumberLabel.textColor = .LabelFont
    }
    func SNPSetPhoneNumberTextField(){
        phoneNumberTextField.snp.makeConstraints { (make) -> Void in
            make.top.equalTo(phoneNumberLabel.snp.top)
            make.left.equalTo(phoneNumberLabel.snp.right).offset(24)
        }
        phoneNumberTextField.font = UIFont(name: "PingFangSC", size: 17)
        phoneNumberTextField.textColor = .LabelFontPlaceHolder
        phoneNumberTextField.layer.borderColor = UIColor.Background.cgColor
    }
    func SNPSetVerificationCodeButton(){
        verificationCodeButton.titleLabel?.font = UIFont(name: "PingFangSC", size: 14)
        verificationCodeButton.setTitle("发送验证码", for: .normal)
        verificationCodeButton.snp.makeConstraints { (make) -> Void in
            make.right.equalTo(-20)
            make.top.equalTo(phoneNumberLabel.snp.top)
            make.height.equalTo(32)
            make.width.equalTo(Utils.adjustLabelWidth(text: verificationCodeButton.title(for: .normal)!, font: (verificationCodeButton.titleLabel?.font)!, height: 32))
        }
        
        verificationCodeButton.setTitleColor(.white, for: .normal)
        verificationCodeButton.backgroundColor = .APP
        verificationCodeButton.layer.cornerRadius = 5
        verificationCodeButton.layer.masksToBounds = true
        verificationCodeButton.layer.borderWidth = 1
        verificationCodeButton.layer.borderColor = UIColor.APP.cgColor
        verificationCodeButton.titleLabel?.adjustsFontSizeToFitWidth = true
    }
    func SNPSetThinLineTop(){
        thinLineTop.snp.makeConstraints { (make) -> Void in
            make.left.equalTo(phoneNumberLabel.snp.left)
            make.right.equalTo(verificationCodeButton.snp.right)
            make.height.equalTo(1)
            make.top.equalTo(phoneNumberTextField.snp.bottom).offset(15)
        }
        thinLineTop.backgroundColor = .ThinLine
    }
    func SNPSetVerificationCodeLabel(){
        verificationCodeLabel.snp.makeConstraints { (make) -> Void in
            make.left.equalTo(phoneNumberLabel.snp.left)
            make.top.equalTo(thinLineTop.snp.bottom).offset(25)
        }
        verificationCodeLabel.font = UIFont(name: "PingFangSC", size: 17)
        verificationCodeLabel.textColor = .LabelFont
        verificationCodeLabel.layer.borderColor = UIColor.Background.cgColor
    }
    func SNPSetVerificationCodeTextField(){
        verificationCodeTextField.snp.makeConstraints { (make) -> Void in
            make.left.equalTo(phoneNumberTextField.snp.left)
            make.top.equalTo(verificationCodeLabel.snp.top)
        }
        verificationCodeTextField.font = UIFont(name: "PingFangSC", size: 17)
        verificationCodeTextField.textColor = .LabelFontPlaceHolder
        verificationCodeTextField.layer.borderColor = UIColor.Background.cgColor
    }
    func SNPSetThinLineBottom(){
        thinLineBottom.snp.makeConstraints { (make) -> Void in
            make.left.equalTo(thinLineTop.snp.left)
            make.right.equalTo(thinLineTop.snp.right)
            make.height.equalTo(1)
            make.top.equalTo(verificationCodeLabel.snp.bottom).offset(15)
        }
        thinLineBottom.backgroundColor = .ThinLine
    }
    func SNPSetLoginButton(){
        weak var weakSelf : LoginViewController? = self
        loginButton.snp.makeConstraints { (make) -> Void in
            make.centerX.equalTo(weakSelf!.view.snp.centerX)
            make.height.equalTo(43)
            make.width.equalTo(280)
            make.top.equalTo(thinLineBottom.snp.bottom).offset(45)
        }
        loginButton.titleLabel?.font = UIFont(name: "PingFangSC", size: 17)
        loginButton.setTitle("登录", for: .normal)
        loginButton.setTitleColor(.white, for: .normal)
//        loginButton.setBackgroundImage(UIImage(named:"loginButtonEnabled"), for: .normal)
//        loginButton.setBackgroundImage(UIImage(named:"loginButtonDisabled"), for: .disabled)
        loginButton.setBackgroundColor(.APP,alpha:1.0, for : .normal)
        loginButton.setBackgroundColor(.APP,alpha:0.5, for : .disabled)
        loginButton.layer.cornerRadius = 10
        loginButton.layer.masksToBounds = true
        loginButton.layer.borderWidth = 0
        loginButton.layer.borderColor = UIColor.APP.cgColor
        loginButton.isEnabled = false
    }
    func SNPSetThirdPartyLoginThinLineLeft(){
        thirdPartyLoginThinLineLeft.snp.makeConstraints { (make) -> Void in
            make.right.equalTo(thirdPartyLoginLabel.snp.left).offset(-14)
            make.height.equalTo(1)
            make.width.equalTo(75)
            make.top.equalTo(thirdPartyLoginLabel.snp.top)
            
        }
        thirdPartyLoginThinLineLeft.backgroundColor = .ThinLine
    }
    func SNPSetThirdPartyLoginLabel(){
        thirdPartyLoginLabel.font = UIFont(name: "PingFangSC", size: 14)
        thirdPartyLoginLabel.text = "第三方登录"
        thirdPartyLoginLabel.textColor = .ThinLine
        weak var weakSelf : LoginViewController? = self
        thirdPartyLoginLabel.snp.makeConstraints { (make) -> Void in
            make.centerX.equalTo(weakSelf!.view.snp.centerX)
            make.width.equalTo(Utils.adjustLabelWidth(text: thirdPartyLoginLabel.text!, font: thirdPartyLoginLabel.font, height: 14))
            make.top.equalTo(loginButton.snp.bottom).offset(105)
        }
    }
    func SNPSetThirdPartyLoginThinLineRight(){
        thirdPartyLoginThinLineRight.snp.makeConstraints { (make) -> Void in
            make.left.equalTo(thirdPartyLoginLabel.snp.right).offset(14)
            make.height.equalTo(1)
            make.width.equalTo(75)
            make.top.equalTo(thirdPartyLoginThinLineLeft.snp.top)
        }
        thirdPartyLoginThinLineRight.backgroundColor = .ThinLine
    }
    func SNPSetQQLoginButton(){
        QQLoginButton.snp.makeConstraints { (make) -> Void in
            make.left.equalTo(76)
            make.width.equalTo(QQLoginButton.snp.height)
            make.top.equalTo(thirdPartyLoginLabel.snp.bottom).offset(30)
        }
        QQLoginButton.setBackgroundImage(UIImage(named:"qq"), for: .normal)
    }
    func SNPSetWechatLoginButton(){
        WechatLoginButton.snp.makeConstraints { (make) -> Void in
            make.left.equalTo(QQLoginButton.snp.right).offset(48)
            make.right.equalTo(WeiboLoginButton.snp.left).offset(-48)
            make.width.height.equalTo(QQLoginButton.snp.height)
            make.top.equalTo(QQLoginButton)
        }
        WechatLoginButton.setBackgroundImage(UIImage(named:"微信"), for: .normal)
    }
    func SNPSetWeiboLoginButton(){
        WeiboLoginButton.snp.makeConstraints { (make) -> Void in
            make.right.equalTo(-76)
            make.width.height.equalTo(QQLoginButton.snp.height)
            make.top.equalTo(QQLoginButton)
        }
        WeiboLoginButton.setBackgroundImage(UIImage(named:"微博"), for: .normal)
    }
    func SNPSetQQLoginLabel(){
        QQLoginLabel.font = UIFont(name: "PingFangSC", size: 14)
        QQLoginLabel.text = "QQ"
        QQLoginLabel.textColor = .ThinLine
//        weak var weakSelf : loginViewController? = self
        QQLoginLabel.snp.makeConstraints { (make) -> Void in
            make.centerX.equalTo(QQLoginButton.snp.centerX)
//            make.width.equalTo(Utils.adjustLabelWidth(text: thirdPartyLoginLabel.text!, font: thirdPartyLoginLabel.font, height: 14))
            make.top.equalTo(QQLoginButton.snp.bottom).offset(10)
        }
    }
    func SNPSetWechatLoginLabel(){
        WechatLoginLabel.font = UIFont(name: "PingFangSC", size: 14)
        WechatLoginLabel.text = "微信"
        WechatLoginLabel.textColor = .ThinLine
        //        weak var weakSelf : loginViewController? = self
        WechatLoginLabel.snp.makeConstraints { (make) -> Void in
            make.centerX.equalTo(WechatLoginButton.snp.centerX)
            //            make.width.equalTo(Utils.adjustLabelWidth(text: thirdPartyLoginLabel.text!, font: thirdPartyLoginLabel.font, height: 14))
            make.top.equalTo(WechatLoginButton.snp.bottom).offset(10)
        }
    }
    func SNPSetWeiboLoginLabel(){
        WeiboLoginLabel.font = UIFont(name: "PingFangSC", size: 14)
        WeiboLoginLabel.text = "微博"
        WeiboLoginLabel.textColor = .ThinLine
        //        weak var weakSelf : loginViewController? = self
        WeiboLoginLabel.snp.makeConstraints { (make) -> Void in
            make.centerX.equalTo(WeiboLoginButton.snp.centerX)
            //            make.width.equalTo(Utils.adjustLabelWidth(text: thirdPartyLoginLabel.text!, font: thirdPartyLoginLabel.font, height: 14))
            make.top.equalTo(WeiboLoginButton.snp.bottom).offset(10)
        }
    }
    override func viewWillDisappear(_ animated: Bool) {
//        如果通知中心有通知就移除
        
    }
    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
